#!/bin/bash -e

TAG=$SNAP_INSTANCE_NAME.$(basename "$0")

# set up postgres, if we are upgrading it
$SNAP/bin/kong-postgres-setup.sh "post-refresh"

# Install the Unit of Measure config file when upgrading from an old version
# UoM was added in v2.3.0-dev.45:
# https://github.com/edgexfoundry/edgex-go/pull/4119
uom="config/core-metadata/res/uom.toml"
logger --tag $TAG "Installing $SNAP/$uom"
if [ -f "$SNAP/$uom" ]; then
    # --no-clobber: copy if missing from target
    cp --no-clobber "$SNAP/$uom" "$SNAP_DATA/$uom"
else
    logger --stderr --tag $TAG "$SNAP/$uom does not exit."
fi
